Print PDF with specified margins in C# with Aspose.PDF - margins are not being applied correctly

I have tried to set margins but the resulting pdf is not printed to edge of paper. Please let me know which exact properties to use in c# or vb.NET.

Hi,


Thank you for contacting support. Please try the following code as narrated below and also refer to this help topic to get an understanding of PDF page properties: Get and Set Page Properties

[.NET, C#]
<span class=“rem” style=“color: rgb(0, 128, 0); font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>// load a PDF<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
Aspose.Pdf.Document document = <span class=“kwrd” style=“color: rgb(0, 0, 255); font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>new<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”> Aspose.Pdf.Document(@“c:\temp\document.pdf”);<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
<span class=“rem” style=“color: rgb(0, 128, 0); font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>// set margins<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>document<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>.PageInfo.Margin.Top = 2;<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>document<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>.PageInfo.Margin.Bottom = 2;<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>document<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>.PageInfo.Margin.Left = 2;<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>document<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>.PageInfo.Margin.Right = 2;<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
<span class=“rem” style=“color: rgb(0, 128, 0); font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>// save PDF document<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
document.Save(@“c:\temp\document.pdf”);
<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>

I am using this:


Dim viewer As New PdfViewer
viewer.BindPdf(myfilepath)

How can I access the document from the viewer object?

I managed to set this. But the problem is not in the original pdf but in the printing of pdf. I have tried setting this:


ps.DefaultPageSettings.Margins.Left = 0
ps.DefaultPageSettings.Margins.Right = 0
ps.DefaultPageSettings.Margins.Top = 0
ps.DefaultPageSettings.Margins.Bottom = 0

But still there is a big margin in the print. I can send you a file so you can see for yourself but the content is secret so I cannot post it here.

Hi,


Thank you for contacting support. We have tested your scenario with one of our PDF samples and managed to replicate the problem incorrect margins. It has been logged under the ticket ID PDFNET-42859 in our bug tracking system. We have linked your post to this ticket and will keep you informed regarding any available updates. We are sorry for the inconvenience caused.

Hi, any update on this? This is a big problem for our customers.

@webmaster6b8e5,

Thanks for your patience.

I am afraid the earlier reported issue is pending for review and is not yet resolved. However the product team will surely consider investigating it as per their development schedule and as soon as we have some further updates, we will let you know.

Your patience and comprehension is greatly appreciated in this regard.

Hi, still now response?

This is a critical feature and one of the sole purposes for purchasing your tool. It has been a very long time and it is also preventing me for renewing the software.

Please talk to the developers about the real status for this.

@webmaster6b8e5,

Thanks for your patience.

I am afraid the earlier reported issue is not yet resolved as the team has been busy fixing other previously reported high priority issues. However as shared earlier, as soon as we have some definite updates, we will let you know. We are sorry for this delay and inconvenience.

Checking in again. A month later. Any update to this?

@webmaster6b8e5

Thanks for your inquiry.

I am afraid that earlier logged issue has not been yet resolved due to large number of pending issues in the queue. However we have recorded your concerns and shared them with the respective team. As soon as we receive some feedback from their side, we will let you know. Please spare us little time.

We are sorry for this inconvenience.

Hi, I am not checking in again one month later. My users are really suffering because of this printing bug.

@webmaster6b8e5

Thanks for your inquiry.

I am afraid that earlier logged issue has not been resolved yet. Product team has been busy in providing fixes to previously logged issues as well as adding new enhancements to the API. We have escalated the issue to next level by raising your concerns to respective team. As soon as we get some feedback from their side, we will let you know. Please spare us little time.

We are sorry for the inconvenience.

Checking in again - a month later. I have now waited 7 months for a fix to just print pdf.

@webmaster6b8e5,

Unfortunately, there is no update on this ticket (PDFNET-42859) yet. We recommend our clients to post their critical issues in the paid support forum. You can post this ticket ID in the paid support forum. Please refer to this help topic: Aspose - Paid Support Helpdesk

One year later. Vital bug. Any update?

@webmaster6b8e5

We are afraid logged ticket has not been scheduled yet. We have recorded your concerns and its priority has been raised to next level. We really appreciate your patience and comprehension in this regard.

Any update? We want to renew the license but it makes no sense if you never fixes issues.

@webmaster6b8e5

Thank you for being patient.

We are afraid PDFNET-42859 is still not resolved. We have recorded your concerns and will schedule it as soon as we can. Please spare us some more time.

Two years later - have you solved printing?