logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Senne  
#1 Posted : Wednesday, June 10, 2020 10:30:41 AM(UTC)
Senne

Rank: Newbie

Groups: Registered
Joined: 6/10/2020(UTC)
Posts: 5
Belgium
Location: Zedelgem

Thanks: 1 times
We are having a small issue when printing our PDF files through the Pdfium library. There is often some text or other information that is printed towards the very bottom of a page, usually detailing where it was printed from and what version of our software was being used, but this text is cropped off.

When printing the same pdf through Adobe or one of our other libraries, this text is displayed just fine, so it is not an issue with the printer itself.
This same bottom text is also cropped out the same way on a page that is printed in Landscape, meaning it is cropped out prior to rotating the page for the printer. It is also cropped out prior to any scaling, as the text is still missing when printed without the PrintSizeMode set to ActualSize.

How would I go about solving this issue?

The code below is how we call the print event. The PrinterSettings are created much earlier elsewhere and are passed down to here.

Code:
PdfCommon.Initialize(PdfLicense.Key);

var doc = PdfDocument.Load(fileName);
var pd = new PdfPrintDocument(doc) { PrinterSettings = settings };
if (settings.MinimumPage == 0)
{
     pd.PrinterSettings.MinimumPage = 1;
}
if (settings.MaximumPage == 9999)
{
     pd.PrinterSettings.MaximumPage = pd.Document.Pages.Count;
}

PrintController printController = new StandardPrintController();
pd.PrintController = printController;
pd.PrintSizeMode = PrintSizeMode.ActualSize;
pd.AutoCenter = true;

pd.Print();
Paul Rayman  
#2 Posted : Wednesday, June 10, 2020 4:56:27 PM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 898

Thanks: 3 times
Was thanked: 110 time(s) in 107 post(s)
What about PrintSizeMode.Fit?
Could you provide such a document to support@patagames.com
Senne  
#3 Posted : Thursday, June 11, 2020 3:35:22 AM(UTC)
Senne

Rank: Newbie

Groups: Registered
Joined: 6/10/2020(UTC)
Posts: 5
Belgium
Location: Zedelgem

Thanks: 1 times
I have just sent a test PDF that showcases the issue to support.

Even when using PrintSizeMode.Fit, the text is still cropped out, so it doesn't seem to have anything to do with the actual area available on a page or any printer-related issues (as the same file printed through a PDF reader like Adobe or Edge prints just fine). We're required to use PrintSizeMode.ActualSize either way to ensure everything is printed in the correct place on the paper we supply to our printer.
Paul Rayman  
#4 Posted : Friday, June 12, 2020 11:32:06 PM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 898

Thanks: 3 times
Was thanked: 110 time(s) in 107 post(s)
We could not reproduce the problem on any of our virtual and physical printers.
We used your document and code below.
May be the problem in this line of code:
Code:
var pd = new PdfPrintDocument(doc) { PrinterSettings = settings };

In our tests, we removed the PrinterSettings and, of course, used the PrintSizeMode.Fit.

Code:
private static void PrintDocument()
{
    var doc = PdfDocument.Load(@"e:\58\Test File Pdfium.pdf");
    var pd = new PdfPrintDocument(doc) { /*PrinterSettings = settings*/ };
    pd.PrinterSettings.MinimumPage = 1;
    pd.PrinterSettings.MaximumPage = pd.Document.Pages.Count;


    PrintController printController = new StandardPrintController();
    pd.PrintController = printController;
    pd.PrintSizeMode = PrintSizeMode.Fit;
    pd.AutoCenter = true;

    pd.Print();
}

Edited by user Friday, June 12, 2020 11:38:04 PM(UTC)  | Reason: Not specified

Senne  
#5 Posted : Monday, June 15, 2020 6:19:59 AM(UTC)
Senne

Rank: Newbie

Groups: Registered
Joined: 6/10/2020(UTC)
Posts: 5
Belgium
Location: Zedelgem

Thanks: 1 times
It is indeed true that PrintSizeMode.Fit prints the text correctly. I should have tested that more thoroughly earlier. However, this does not solve our issue, as we specifically do not want the pdf to be scaled down to fit. We absolutely must have the actual size printed, and while this proves to be no issue for other print-tools such as Microsoft Edge or Adobe Acrobat Reader, it strangely does not work with Pdfium.

It also does not seem to be an issue with our printersettings, as commenting them out changes nothing of the end result.
Below is a picture I took of the issue, as well as the code used for each page.

IMG_20200615_115223.jpg (44kb) downloaded 2 time(s).

Left page:
Code:

var doc = PdfDocument.Load(fileName);
var pd = new PdfPrintDocument(doc) { /*PrinterSettings = settings*/ };
pd.PrinterSettings.MinimumPage = 1;
pd.PrinterSettings.MaximumPage = pd.Document.Pages.Count;

PrintController printController = new StandardPrintController();
pd.PrintController = printController;

pd.PrintSizeMode = PrintSizeMode.Fit;
pd.AutoCenter = true;

pd.Print();


Middle page (text is cropped off):
Code:

var doc = PdfDocument.Load(fileName);
var pd = new PdfPrintDocument(doc) { /*PrinterSettings = settings*/ };
pd.PrinterSettings.MinimumPage = 1;
pd.PrinterSettings.MaximumPage = pd.Document.Pages.Count;

PrintController printController = new StandardPrintController();
pd.PrintController = printController;

pd.PrintSizeMode = PrintSizeMode.ActualSize;
pd.AutoCenter = true;

pd.Print();


Right page (what we want to see):
Printed through Adobe Acrobat Reader, with "Actual Size" option set.
Paul Rayman  
#6 Posted : Monday, June 15, 2020 7:41:01 AM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 898

Thanks: 3 times
Was thanked: 110 time(s) in 107 post(s)
The page size is 8.27x11.69 inches, What about PrintableArea and/or PageSize in your printer settings?
Senne  
#7 Posted : Monday, June 15, 2020 8:03:42 AM(UTC)
Senne

Rank: Newbie

Groups: Registered
Joined: 6/10/2020(UTC)
Posts: 5
Belgium
Location: Zedelgem

Thanks: 1 times
The pd.PrinterSettings.DefaultPageSettings.PrintableArea for the default PrinterSettings (so with our own still commented out, as in the previous reply) appears to be X = 16.666666, Y = 19.666666, Width = 793.3333, Height = 1129.83337

Both height and width do appear to be a little lower than the page size, which is the same as you said, 8.27 x 11.69 inches, but the difference doesn't seem large enough to cause this issue. I will see if I can adjust this value and what the result is then. It's clear that our printer is fully capable of printing said text with for example Adobe Acrobat Reader, so is there a chance the PrintableArea is misinterpreted somehow by Pdfium?

Edited by user Monday, June 15, 2020 8:04:41 AM(UTC)  | Reason: Not specified

Paul Rayman  
#8 Posted : Monday, June 15, 2020 8:59:29 AM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 898

Thanks: 3 times
Was thanked: 110 time(s) in 107 post(s)
Originally Posted by: Senne Go to Quoted Post
The pd.PrinterSettings.DefaultPageSettings.PrintableArea for the default PrinterSettings (so with our own still commented out, as in the previous reply) appears to be X = 16.666666, Y = 19.666666, Width = 793.3333, Height = 1129.83337


PrintableArea is 7.93x11.29 inches. The printer cannot print outside this area.
https://docs.microsoft.c...view=dotnet-plat-ext-3.1
Quote:
A RectangleF representing the length and width, in hundredths of an inch, of the area the printer is capable of printing in.

Quote:
You can use this property to print outside the margins of the page, but within the printable area.


Currently I don't know how Adobe do that.

Edited by user Monday, June 15, 2020 9:00:04 AM(UTC)  | Reason: Not specified

Senne  
#9 Posted : Monday, June 15, 2020 9:24:53 AM(UTC)
Senne

Rank: Newbie

Groups: Registered
Joined: 6/10/2020(UTC)
Posts: 5
Belgium
Location: Zedelgem

Thanks: 1 times
I've double checked with Word to make sure that the text is within the printable area, and it absolutely is. The image below is the printable area as shown in Word (by first setting the margins to 0 and then hitting "Fix" on the warning).
The math also checks out, the A4 width/height - the margins = 7.93x11.29. The PDF at actual size is shown to clearly be within those bounds.

pdfiumissue.png (13kb) downloaded 4 time(s).

The PDF prints perfectly fine at actual size using:
- Microsoft Edge
- Adobe Acrobat Reader
- PdfPrintingNet, a different NuGet library

The issue only presents itself using Pdfium out of the various methods I've tried, so surely there's a problem somewhere?

Edited by user Monday, June 15, 2020 9:26:14 AM(UTC)  | Reason: Not specified

Paul Rayman  
#10 Posted : Monday, June 15, 2020 10:00:30 AM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 898

Thanks: 3 times
Was thanked: 110 time(s) in 107 post(s)
We will fix it on a week
thanks 1 user thanked Paul Rayman for this useful post.
Senne on 6/15/2020(UTC)
Paul Rayman  
#11 Posted : Sunday, June 21, 2020 5:43:27 AM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 898

Thanks: 3 times
Was thanked: 110 time(s) in 107 post(s)
Fixed!
Please update to the latest version (4.29.2704)

You can print the document in this way
Code:
pd.PrintSizeMode = PrintSizeMode.ActualSize;
pd.AutoCenter = true;
pd.Print();


or this
Code:
pd.PrintSizeMode = PrintSizeMode.ActualSize;
pd.OriginAtMargins = true;
pd.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0);
pd.Print();

Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.