PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Apr 26, 2024 7:44 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: Tue Feb 10, 2015 10:24 am 
Offline

Joined: Tue Jan 13, 2015 3:33 pm
Posts: 10
Hello,

I am creating Charts using phantomjs + Charts and want to integrate them to my PDF file.

In the attached file Original.png you can find the original image I am loading into the pdf.

Attachment:
Original.png
Original.png [ 33.63 KiB | Viewed 10407 times ]


In the attached file PDF.png you can find a screenshot of how the image looks in the pdf.

Attachment:
PDF.PNG
PDF.PNG [ 39.33 KiB | Viewed 10407 times ]


The Code for integrating the image is as follows:

Code:
    var image = new Image(vsChartImage);
    image.Width = Unit.FromCentimeter(15);

    Table table = document.LastSection.AddTable();

    table.Borders.Visible = false;

    Column col = table.AddColumn();
    col.Format.Alignment = ParagraphAlignment.Left;
    col.Width = Unit.FromCentimeter(16);
    col = table.AddColumn();
    col.Format.Alignment = ParagraphAlignment.Right;
    col.Width = Unit.FromCentimeter(8);

    Row row = table.AddRow();
    row.Cells[0].Add(image);


Here vsChartImage is the path of the Image.

How can I remove the borders drawn around the image?


Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 10, 2015 10:38 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
Hi!

I pasted your code into the Hello World sample and I don't see any borders. I used "Original.png" instead of vsChartImage and opened the file with Adobe Reader XI.

Time for an SSCCE.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 10, 2015 1:55 pm 
Offline

Joined: Tue Jan 13, 2015 3:33 pm
Posts: 10
I now first tried to comment out every step until the problem didn't exist anymore.

I then went one step back and copied the code to a new console project. (
Attachment:
Program.zip [1.16 KiB]
Downloaded 366 times
)

When I now run the new project I can't reproduce the error.

The only difference is that the live Code is an ASP.Net project and the code is called from WebAPI.

The locally saved files of the web application have the bug in them, while the ones generated from the console project don't.

Any ideas?


Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 10, 2015 2:12 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
Have you tried both builds (GDI+ and WPF)? Maybe the other one works on the server, too.
Or try a server with a different Windows version (if available).

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Wed Feb 11, 2015 8:40 am 
Offline

Joined: Tue Jan 13, 2015 3:33 pm
Posts: 10
Sadly neither GDI+ nor WPF give the desired output.

I tried with both stable and beta versions from NuGet.

Any other idea? I will try to build a small website for recreating the error.


Top
 Profile  
Reply with quote  
PostPosted: Wed Feb 11, 2015 8:53 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
Can you try other formats than PNG (GIF, BMP, TIFF) or maybe different PNG files?

The PDF files created on the server are different from the PDF files created on the workstation, right?
Are the PNG files identical?

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Wed Feb 11, 2015 9:50 am 
Offline

Joined: Tue Jan 13, 2015 3:33 pm
Posts: 10
Both programs are running on my local machine right now.
One is console application the other one is a website running on my local IIS Express.

The console application puts out everything just fine, while the web application has this problem.


Top
 Profile  
Reply with quote  
PostPosted: Wed Feb 11, 2015 10:43 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
D_F_G wrote:
The console application puts out everything just fine, while the web application has this problem.
Mysterious.

Are you embedding generated charts or are you reading the chart from the same PNG file?

Same .NET versions for both projects?

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Wed Feb 11, 2015 11:10 am 
Offline

Joined: Tue Jan 13, 2015 3:33 pm
Posts: 10
I am embedding generated charts (in png format) in the web application.

In the console version I embed one of the generated pngs.

Also it's the same version of .Net and PdfSharp/MigraDoc


Top
 Profile  
Reply with quote  
PostPosted: Wed Feb 11, 2015 11:14 am 
Offline

Joined: Tue Jan 13, 2015 3:33 pm
Posts: 10
Seems like an error in Adobe Reader.
A colleague using 11.0.5 doesn't have any borders, while I have borders using 11.0.10.
But still it seems weird that I don't have the borders in the console application.


Top
 Profile  
Reply with quote  
PostPosted: Mon Feb 23, 2015 10:01 am 
Offline

Joined: Tue Jan 13, 2015 3:33 pm
Posts: 10
I found the problem, but not why it was there only in some cases.

The problem was with phantomjs (the headless browser used to generate the images). Here a transparent background was used. it was 1px around the image. Since the image was resized when put into the pdf the border was probably less than 1px and sometimes appeared as a border.

Setting the background color to white helped.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 321 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group