PD4ML v4 Forums PD4ML v3 Archived Forums (Read Only) General questions / FAQ Unable to create the PDF file using PD4ML.NET

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #26419

    Hello PD4ML Support Team,

    I am using the below posted code to generate PD4ML from asp.net application. Every thing till the file creation process works fine except it is throwing a permissions error when application tried to save the PDF. I am an admin on my Box. Can you help me to solve the permissions issue please?
    Same time Can you also validate the stuff that I am doing below is proper as well.
    {I did use VB.NET with framework 3.5 and PD4ML.NET during this task.Hope this helps}
    '.................Purpose of the File ......................................................................<br /> 'Title: Test.<br /> 'This page will be used to testBuild any new functionality independently.<br /> '................................................................................................................<br /> Imports org.zefer.pd4ml<br /> Imports System.IO<br /> <br /> ''' <summary><br /> '''<br /> ''' </summary><br /> Partial Class PD4MLTest<br /> Inherits System.Web.UI.Page<br /> 'Protected Shared USAGE As String = "Usage: pd4net.exe '<url>' <htmlWidth> [pageFormat] [-permissions <NUMBER>]" & _<br /> '"[-bookmarks <HEADINGS|ANCHORS>] [-orientation <PORTRAIT|LANDSCAPE>] " & _<br /> '"[-ttf <ttf_fonts_dir>] [-out <output_file_path>]"<br /> <br /> Protected Shared strUsage As String<br /> Protected Shared USAGE As ArrayList = New ArrayList()<br /> <br /> <br /> <br /> ''' <summary><br /> ''' Handles the Load event of the Page control.<br /> ''' </summary><br /> ''' <param name="sender">The source of the event.</param><br /> ''' <param name="e">The <see cref="System.EventArgs" /> instance containing the event data.</param><br /> Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load<br /> USAGE.Add("http://localhost:3013/web/Default.aspx")<br /> USAGE.Add(500)<br /> USAGE.Add("A4")<br /> USAGE.Add(1)<br /> USAGE.Add("HEADINGS")<br /> USAGE.Add("PORTRAIT")<br /> USAGE.Add("c:windowsfonts")<br /> USAGE.Add("C:P")<br /> strUsage = String.Format("Usage: pd4net.exe {0}, {1}, {2}, -permissions {3}, -bookmarks {4}, -orientation {5}, - ttf {6},-out {7}", USAGE(0), USAGE(1), USAGE(2), USAGE(3), USAGE(4), USAGE(5), USAGE(6), USAGE(7))<br /> Main(USAGE)<br /> 'Converter.generatePDF(infile, width, Format, permissions, bookmarks, Orientation, ttf, outfile)<br /> End Sub<br /> ''' <summary><br /> ''' Generates the PDF.<br /> ''' </summary><br /> ''' <param name="inputUrl">The input URL.</param><br /> ''' <param name="htmlWidth">Width of the HTML.</param><br /> ''' <param name="pageFormat">The page format.</param><br /> ''' <param name="permissions">The permissions.</param><br /> ''' <param name="bookmarks">The bookmarks.</param><br /> ''' <param name="orientation">The orientation.</param><br /> ''' <param name="fontsDir">The fonts dir.</param><br /> ''' <param name="outfile">The outfile.</param><br /> Protected Sub generatePDF(ByVal inputUrl As String, ByVal htmlWidth As Integer, ByVal pageFormat As String, ByVal permissions As Integer, ByVal bookmarks As String, ByVal orientation As String, ByVal fontsDir As String, ByVal outfile As String)<br /> Dim pd4ml As PD4ML = New PD4ML()<br /> <br /> pd4ml.HtmlWidth = htmlWidth<br /> <br /> If (orientation = Nothing Or orientation.Trim.Length = 0) Then<br /> orientation = "portrait"<br /> End If<br /> <br /> If ("PORTRAIT".Equals(orientation.ToUpper())) Then<br /> pd4ml.PageSize = PD4Constants.getSizeByName(pageFormat)<br /> Else<br /> pd4ml.PageSize = pd4ml.changePageOrientation(PD4Constants.getSizeByName(pageFormat))<br /> End If<br /> <br /> If (permissions <> -1) Then<br /> pd4ml.setPermissions("empty", permissions, True)<br /> End If<br /> <br /> If (bookmarks <> Nothing AndAlso bookmarks.Trim.Length > 0) Then<br /> If ("ANCHORS".Equals(bookmarks.ToUpper())) Then<br /> pd4ml.generateOutlines(False)<br /> ElseIf ("HEADINGS".Equals(bookmarks.ToUpper())) Then<br /> pd4ml.generateOutlines(True)<br /> End If<br /> End If<br /> <br /> If (fontsDir <> Nothing AndAlso fontsDir.Length > 0) Then<br /> pd4ml.useTTF(fontsDir, True)<br /> End If<br /> <br /> If (outfile = Nothing OrElse outfile.Equals("-")) Then<br /> pd4ml.render(New Uri(inputUrl), Console.Out)<br /> Else<br /> pd4ml.render(New Uri(inputUrl), New System.IO.FileStream(outfile, System.IO.FileMode.Create))<br /> End If<br /> End Sub<br /> ''' <summary><br /> ''' Wrongs the param.<br /> ''' </summary><br /> ''' <param name="msg">The MSG.</param><br /> Protected Shared Sub wrongParam(ByVal msg As String)<br /> Console.Out.WriteLine("invalid parameter: " + msg)<br /> Console.Out.WriteLine(USAGE)<br /> End Sub<br /> <br /> <br /> <br /> ''' <summary><br /> ''' Mains the specified args.<br /> ''' </summary><br /> ''' <param name="args">The args.</param><br /> Private Shared Sub Main(ByVal args As ArrayList)<br /> 'Private Shared Sub Main(ByVal args As string())<br /> ' converter.generatePDF(infile, width, format, permissions, bookmarks, orientation, ttf, outfile)<br /> Dim infile As String = args(0).ToString<br /> Dim width As Integer = CInt(args(1))<br /> Dim format As String = args(2).ToString<br /> Dim permissions As Integer = args(3).ToString<br /> Dim bookmarks As String = args(4).ToString<br /> Dim orientation As String = args(5).ToString<br /> Dim ttf As String = args(6).ToString<br /> Dim outfile As String = args(7).ToString<br /> Dim formatSet As Boolean = False<br /> Dim ff As FileInfo = Nothing<br /> Dim i As Integer<br /> <br /> For i = 0 To i < args.Count<br /> 'For i = 0 To i < args.Length<br /> <br /> If ("-permissions".Equals(args(i))) Then<br /> i = i + i<br /> 'If (i = args.Length) Then<br /> If (i = args.Count) Then<br /> wrongParam("missing permissions number (a sum of single permission codes)")<br /> Return<br /> End If<br /> permissions = Int32.Parse(args(i))<br /> Continue For<br /> End If<br /> <br /> If ("-bookmarks".Equals(args(i))) Then<br /> i = i + i<br /> If (i = args.Count) Then<br /> wrongParam("missing bookmark type (HEADINGS or ANCHORS)")<br /> Return<br /> End If<br /> bookmarks = args(i)<br /> Continue For<br /> End If<br /> <br /> If ("-orientation".Equals(args(i))) Then<br /> i = i + i<br /> If (i = args.Count) Then<br /> wrongParam("missing orientation type (PORTRAIT or LANDSCAPE)")<br /> Return<br /> End If<br /> orientation = args(i)<br /> Continue For<br /> End If<br /> <br /> If ("-ttf".Equals(args(i))) Then<br /> i = i + i<br /> If (i = args.Count) Then<br /> wrongParam("missing TTF fonts directory")<br /> Return<br /> End If<br /> ff = New FileInfo(args(i))<br /> ttf = ff.FullName<br /> Continue For<br /> End If<br /> <br /> If ("-out".Equals(args(i))) Then<br /> i = i + i<br /> If (i = args.Count) Then<br /> wrongParam("missing output file name")<br /> Return<br /> End If<br /> outfile = args(i)<br /> Continue For<br /> End If<br /> <br /> If (args(i).StartsWith("-")) Then<br /> wrongParam("unknown: " + args(i))<br /> Return<br /> End If<br /> <br /> If (infile = Nothing) Then<br /> Dim ss As String = args(i)<br /> If Not (ss.StartsWith("http://") AndAlso ss.StartsWith("file://")) Then<br /> ff = New FileInfo(ss)<br /> infile = "file:///" & ff.FullName<br /> Else<br /> infile = ss<br /> End If<br /> Continue For<br /> End If<br /> <br /> If (width = -1) Then<br /> width = Int32.Parse(args(i))<br /> Continue For<br /> End If<br /> <br /> If (Not formatSet) Then<br /> formatSet = True<br /> format = args(i)<br /> Continue For<br /> End If<br /> wrongParam(args(i))<br /> Return<br /> Next i<br /> <br /> If (infile = Nothing) Then<br /> Console.Out.WriteLine("source URL is missing")<br /> Console.Out.WriteLine(USAGE)<br /> Return<br /> End If<br /> <br /> If (width = -1) Then<br /> Console.Out.WriteLine("HTML width parameter is missing")<br /> Console.Out.WriteLine(USAGE)<br /> Return<br /> End If<br /> <br /> Dim converter As PD4MLTest = New PD4MLTest<br /> converter.generatePDF(infile, width, format, permissions, bookmarks, orientation, ttf, outfile)<br /> <br /> End Sub<br /> End Class

    Thanks and Regards,
    Venky

    #28111

    In fact ASP.NET pages are works under IIS with limited user creentials; so please check the following:

    1. Please check your application have writing permissions. Usually it are disabled.

    2. If your folder is out of IIS folders scope, please check you set write access to everyone or to at least local IUSR_* users.

Viewing 2 posts - 1 through 2 (of 2 total)

The forum ‘General questions / FAQ’ is closed to new topics and replies.