0
如何創建pdf到gcs中,並插入一些數據?如何將內容寫入pdf? Google雲端存儲服務
這是我的代碼:
GcsService gcsService = GcsServiceFactory.createGcsService(new RetryParams.Builder() .initialRetryDelayMillis(10) .retryMaxAttempts(10) .totalRetryPeriodMillis(15000) .build()); GcsFilename filename = new GcsFilename("areteaics", "test.pdf"); GcsFileOptions options = new GcsFileOptions.Builder().mimeType("application/pdf").build(); GcsOutputChannel writeChannel = gcsService.createOrReplace(filename,options); PrintWriter out = new PrintWriter(Channels.newWriter(writeChannel, "UTF8")); //out.println("The woods are lovely dark and deep."); //out.println("But I have promises to keep."); //out.flush(); writeChannel.waitForOutstandingWrites(); //writeChannel.write(ByteBuffer.wrap("And miles to go before I sleep.".getBytes())); writeChannel.close();
問題是,當我嘗試打開PDF文件 - 在雲存儲的控制檯中 - 表示該文件已損壞。 – user3009757