title: XF skiasharp downloads corrupted PDF
body: <p>I want to create PDF reports using Xamarin Forms. I have tried creating sample PDF usin <code>skiasharp</code> plugin. But I am facing strange problem.</p>
  <p>PDF can be opened in Mobile Device(Android 10.0, API 29) very easily. but if I try to open same PDF in laptop then it shows error message saying <strong>Can not open corrupted PDF</strong>.</p>
  <p>Also if we look at size of the PDF, It is 183 KB in device and 0KB in laptop.</p>
  <p><strong>Code</strong></p>
  <pre><code>private void GenerateDocument()
          {
              try
              {
                  var root = EnsureTempDataDirectory(&quot;CreatePdfSample&quot;);
                  path = Path.Combine(root, $&quot;{Guid.NewGuid():N}.pdf&quot;);
                  
                  if (!isSupported || (isSupported &amp;&amp; File.Exists(path)))
                      return;
  
                  var metadata = new SKDocumentPdfMetadata
                  {
                      Author = &quot;Cool Developer&quot;,
                      Creation = DateTime.Now,
                      Creator = &quot;Cool Developer Library&quot;,
                      Keywords = &quot;SkiaSharp, Sample, PDF, Developer, Library&quot;,
                      Modified = DateTime.Now,
                      Producer = &quot;SkiaSharp&quot;,
                      Subject = &quot;SkiaSharp Sample PDF&quot;,
                      Title = &quot;Sample PDF&quot;,
                  };
  
                  var stream = SKFileWStream.OpenStream(path);
                  var document = SKDocument.CreatePdf(path, metadata);
  
                  if (document == null)
                  {
                      isSupported = false;
                      return;
                  }
  
                  var paint = new SKPaint
                  {
                      TextSize = 64.0f,
                      IsAntialias = true,
                      Color = 0xFF9CAFB7,
                      IsStroke = true,
                      StrokeWidth = 3,
                      TextAlign = SKTextAlign.Center
                  };
  
                  var pageWidth = 840;
                  var pageHeight = 1188;
  
                  // draw page 1
                  using (var pdfCanvas = document.BeginPage(pageWidth, pageHeight))
                  {
                      // draw button
                      var nextPagePaint = new SKPaint
                      {
                          IsAntialias = true,
                          TextSize = 16,
                          Color = SKColors.OrangeRed
                      };
                      var nextText = &quot;Next Page &gt;&gt;&quot;;
                      var btn = new SKRect(pageWidth - nextPagePaint.MeasureText(nextText) - 24, 0, pageWidth, nextPagePaint.TextSize + 24);
                      pdfCanvas.DrawText(nextText, btn.Left + 12, btn.Bottom - 12, nextPagePaint);
                      // make button link
                      pdfCanvas.DrawLinkDestinationAnnotation(btn, &quot;next-page&quot;);
  
                      // draw contents
                      pdfCanvas.DrawText(&quot;...PDF 1/2...&quot;, pageWidth / 2, pageHeight / 4, paint);
                      document.EndPage();
                  }
  
                  // draw page 2
                  using (var pdfCanvas = document.BeginPage(pageWidth, pageHeight))
                  {
                      // draw link destintion
                      pdfCanvas.DrawNamedDestinationAnnotation(SKPoint.Empty, &quot;next-page&quot;);
  
                      // draw contents
                      pdfCanvas.DrawText(&quot;...PDF 2/2...&quot;, pageWidth / 2, pageHeight / 4, paint);
                      document.EndPage();
                  }
  
                  // end the doc
                  document.Close();
              }
              catch (Exception ex)
              {
  
                  throw;
              }
          }
  </code></pre>
  <p>For sample, I have taken reference from <code>Skiasharp</code> Sample available on github.
  Any help would be appreciated</p>
  <p><strong>Edit</strong></p>
  <p>As I have Created folder named CreatePDFSample, path of the file is</p>
  <pre><code>/Internal Storage/Download/CreatePdfSample/8c134318ca8d49f59d7a57e244845107.pdf
  </code></pre>
  <p>One more thing I noted right now, One of the 10-12 files I have created is opening in laptop as well. It is also at the same path. I can't understand what might be issue here.</p>
  <p>Thanks</p>